package com.xiaoc.bulldozer.common.util;


import java.text.DateFormat;
import java.text.SimpleDateFormat;

public class ThreadLocalUtil {

    private static final ThreadLocal<DateFormat> THREADLOCAL_DATEFORMAT = new ThreadLocal<DateFormat>();
    
    public static DateFormat getDateFormat_yyyyMMddHHmmss(){  
        DateFormat dateFormat = THREADLOCAL_DATEFORMAT.get();  
        if(dateFormat==null){  
            dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");  
            THREADLOCAL_DATEFORMAT.set(dateFormat);  
        }  
        return dateFormat;  
    }


    public static DateFormat getDateFormat(String pattern){
        DateFormat dateFormat = THREADLOCAL_DATEFORMAT.get();
        if(dateFormat==null){
            dateFormat = new SimpleDateFormat(pattern);
            THREADLOCAL_DATEFORMAT.set(dateFormat);
        }
        return dateFormat;
    }

}
